package lec09.pm;

import java.util.PriorityQueue;
import java.util.Queue;

public class Apple1 {
	public static void main(String[] args) {
		int a[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
		int tot = 0;
		Queue<Integer> pq = new PriorityQueue<Integer>();
		for (int i : a)
			pq.add(i);
		while (pq.size() >=2) {
			int ia = pq.poll();
			int ib = pq.poll();
			pq.add(ia + ib);
			tot += ia + ib;
			System.out.println(pq);
		}
		System.out.println(tot);

	}
}
